package com.service.dao.enums;

import com.google.common.collect.Lists;
import lombok.Getter;
import org.springframework.lang.Nullable;

import java.util.List;

/**
 * <dl>
 * <dt>back-end</dt>
 * <dd>Description:</dd>
 * <dd>Copyright: Copyright (C) 2015</dd>
 * <dd>Company: </dd>
 * <dd>CreateDate: 2019年09月20日</dd>
 * </dl>
 *
 * @author
 */
public class WalletEnums {


    public enum Status {

        ACTIVE(1, "未使用"),
        INVALID(2, "已使用");

        @Getter
        private Integer code;

        @Getter
        private String msg;

        Status(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }
    }

    public enum Type {
        ALL(0,"ALL"),
        OMNI(1,"OMNI"),
        ERC20(2,"ERC20"),
        TRC20(3,"TRC20"),
        BTC(4,"BTC"),
        ETH(5,"ETH"),
        IPFS(6,"IPFS"),
        CHIA(7,"CHIA"),
        SWARM(8,"SWARM"),
        PHALA(9,"PHALA"),;

        @Getter
        private Integer code;

        @Getter
        private String name;

        Type(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public static Type valueOf(int statusCode) {
            Type status = resolve(statusCode);
            if (status == null) {
                throw new IllegalArgumentException("No matching constant for [" + statusCode + "]");
            }
            return status;
        }

        @Nullable
        public static Type resolve(int statusCode) {
            for (Type status : values()) {
                if (status.code == statusCode) {
                    return status;
                }
            }
            return null;
        }
    }

    public enum BizType{
        recharge(1,"recharge"),
        withdraw(2,"withdraw");

        @Getter
        private Integer code;
        @Getter
        private String name;

        BizType(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public static BizType valueOf(int statusCode) {
            BizType status = resolve(statusCode);
            if (status == null) {
                throw new IllegalArgumentException("No matching constant for [" + statusCode + "]");
            }
            return status;
        }

        @Nullable
        public static BizType resolve(int statusCode) {
            for (BizType status : values()) {
                if (status.code == statusCode) {
                    return status;
                }
            }
            return null;
        }
    }


    /**
     * 可充值的钱包地址
     * @return
     */
    public static List<Integer> getRechargeTypes() {
        return Lists.newArrayList(Type.ERC20.getCode(), Type.TRC20.getCode());
    }

}
